<%-- 
    Document   : Articulo
    Created on : 27/06/2013, 01:12:53 PM
    Author     : SHAI
--%>

<%@page import="bean.Articulo"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="beanUsr" class="bean.Usuario" scope="session" />
<jsp:useBean id="gArticulo" class="bean.gestionArticulos" scope="session" />             
<jsp:useBean id="Articulo" class="bean.Articulo" scope="session" />  
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <link rel="stylesheet" type="text/css" href="css/styleArticulos.css">
        <title>Gestion de Articulos</title>
    </head>
    <body>
        <jsp:include page="header.jsp"/>
        <div id="main">

            <div id="control">
                <div id="controli">
                    <form id="txt" action="accion.jsp" method="post" >
                        <%
                            String value = request.getParameter("articulo");
                            if (beanUsr.isActive()) {
                                if (beanUsr.getRol() >= 1) {
                                    out.print("<input type=\"button\" value=\"Nuevo Articulo\" onClick=\"window.location='articulo.jsp?articulo=nuevo'\">");
                                    out.print("<input type=\"hidden\" name=\"accion\" value=\"guardar\">");
                                    out.print("<input type=\"submit\" value=\"Guardar\">");
                                    if (value.compareTo("nuevo") == 0) {
                                        //out.print("&nbsp;&nbsp;<a href=\"accion.jsp?accion=guardar&idArt=-1" + "\" >Guardar</a>");
                                        out.print("<input type=\"hidden\" name=\"idArt\" value=\"-1\">");

                                    } else {
                                        //out.print("&nbsp;&nbsp;<a href=\"accion.jsp?accion=guardar&idArt=" + value + "" + "\" >Guardar</a>");
                                        out.print("<input type=\"hidden\" name=\"idArt\" value=\"" + value + "\">");
                                    }

                                }
                            }
                        %>
                    </form>
                </div>
                <div id="controld">
                    <form id="Login" action="listaArticulos.jsp" method="post" >
                        <div class="form_settings">
                            <p><span>Buscar:</span><input class="contact" type="text" name="articulo" value="" /></p>
                        </div>
                    </form>
                </div>
            </div>
            <div id="contenido">
                <div id="textoLectura">
                    <%
                        if (value.compareTo("nuevo") == 0) {
                            Articulo = new Articulo(0, "", "", "", "", 0, 1, 0);
                        } else {
                            Articulo = gArticulo.getArticulo(Integer.parseInt(value));
                        }%>
                    Titulo: <input form="txt" id="tituloEditar" type="text" name="titulo" value="<%out.print(Articulo.getTitulo());%>"></br>
                    <textArea id="contenidoEditar" name="contenido" form="txt"><%out.print(Articulo.getContenido());%></textarea>
                </div>
            </div>
            <div id="info">
               <div id="infoi">
                    <%  out.print("&nbsp;&nbsp;Autor: " + Articulo.getAutor() + "</br>");
                        out.print("&nbsp;&nbsp;Fecha: " + Articulo.getFecha() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Punteo: " + Articulo.getPunteo() + "</br>");
                        out.print("&nbsp;&nbsp;Revision: " + Articulo.getRevision() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cantidad de Votos: " + Articulo.getCantidadVotos() + "</br>");
                    %>
                </div>
                <div id="infod">
                    
                </div>
            </div>
        </div>
    </body>
</html>
